define(['app'], function (app) {
    app.controller('classmodCtrl', function ($scope,$rootScope,$http) {
        $('body').scrollTop(0);
        layui.use('form', function() {
            var form = layui.form;
            //监听提交
            form.on('submit(formDemo)', function(data) {
                console.log(data.field)
                $http({
                    url:"/OSRS/clazz/changeClazz",
                    method:"POST",
                    data:JSON.stringify(data.field)
                }).then(function (res) {
                    alert(res.data)
                },function (err) {
                    alert("错误~修改失败!")
                })
                return false;
            });
            form.render();
        });
        $http({
            url:"/OSRS/clazz/getClazzType",
            method:"get"
        }).then(function (res) {
            console.log(res.data)
            $scope.clazzs = res.data;
        },function (err) {
            console.log(err)
        })

        $scope.myclazz=function (clazzid) {
            if(clazzid != ""){
                $http({
                    url:"/OSRS/clazz/getClazz",
                    method:"post",
                    data:clazzid
                }).then(function (res) {
                    console.log(res.data)
                    $scope.cl = res.data;
                },function (err) {
                    console.log(err)
                })
            }else{
                $scope.cl = "";
            }

        }

        $scope.myFun=function (myValue) {
               if(myValue!=""){
                   $http({
                       url:"/OSRS/clazz/getClazzs",
                       method:"post",
                       data:myValue
                   }).then(function (res) {
                       $scope.c = res.data;
                       document.getElementById("chonseOne").options[0].selected = true;
                   },function (err) {
                       console.log(err)
                   })
               }else{
                   $scope.c ="";
               }


        }
    });
}); 
